﻿using EFEntity;
using Iservices;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class third_kindServices : Ithird_kindServices
    {
        private readonly MyDbContext myDbContext;

        public third_kindServices(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }

        public Task<int> Add(config_file_third_kind fd)
        {
            throw new NotImplementedException();
        }

        public Task<int> Delete(int id)
        {
            throw new NotImplementedException();
        }

        public Task<config_file_third_kind> seleceById(int id)
        {
            throw new NotImplementedException();
        }

        public async Task<List<config_file_third_kind>> selectAll()
        {
            List<Econfig_file_third_kind> list = new List<Econfig_file_third_kind>();
            await Task.Run(() =>
            {
                list = myDbContext.config_file_third_kind.ToList();
            });
            List<config_file_third_kind> list2 = new List<config_file_third_kind>();
            foreach (Econfig_file_third_kind item in list)
            {
                config_file_third_kind fd = new config_file_third_kind()
                {
                    ftk_id = item.ftk_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    third_kind_id = item.third_kind_id,
                    third_kind_is_retail = item.third_kind_is_retail,
                    third_kind_name = item.third_kind_name,
                    third_kind_sale_id = item.third_kind_sale_id
                };
                list2.Add(fd);
            }
            return list2;
        }

        public async Task<List<config_file_third_kind>> GetSecondId(string ids)
        {
            List<Econfig_file_third_kind> elist = new List<Econfig_file_third_kind>();
            List<config_file_third_kind> list = new List<config_file_third_kind>();
            await Task.Run(() =>
            {
                elist = (from e in myDbContext.config_file_third_kind
                         where e.second_kind_id == ids
                         select e).ToList();
                foreach (Econfig_file_third_kind item in elist)
                {
                    config_file_third_kind config = new config_file_third_kind()
                    {
                        ftk_id = item.ftk_id,
                        first_kind_id = item.first_kind_id,
                        first_kind_name = item.first_kind_name,
                        second_kind_id = item.second_kind_id,
                        second_kind_name = item.second_kind_name,
                        third_kind_id = item.third_kind_id,
                        third_kind_is_retail = item.third_kind_is_retail,
                        third_kind_name = item.third_kind_name,
                        third_kind_sale_id = item.third_kind_sale_id
                    };
                    list.Add(config);
                }
            });
            return list;
        }

        public Task<int> update(config_file_third_kind fd)
        {
            throw new NotImplementedException();
        }
    }
}
